import { request } from 'umi';

export async function fakeSubmitForm(params: any) {
  return request('/api/userCase/save', {
    method: 'POST',
    data: params,
  });
}

export async function addRecordCase(params: any) {
  return request('/api/userCaseVisit/save', {
    method: 'POST',
    data: params,
  });
}

export async function addCase(params: any) {
  return request('/api/caseManage/save', {
    method: 'POST',
    data: params,
  });
}

export async function queryRecordDetail(params: any) {
  return request('/api/userCaseVisit/' + params.id, {
    method: 'get',
    data: params,
  });
}

export async function updateRecord(params: any) {
  return request('/api/userCaseVisit/updateById', {
    method: 'PUT',
    data: params,
  });
}

export async function updateCaseNew(params: any) {
  return request('/api/caseManage/updateById', {
    method: 'PUT',
    data: params,
  });
}

export async function updateShareAndView(params: any) {
  return request(
    '/api/caseManage/updateViewsOrShares?type=' +
    params.type +
    '&count=' +
    params.count +
    '&id=' +
    params.id,
    {
      method: 'get',
      data: params,
    },
  );
}

export async function queryCaseDetail(params: any) {
  return request('/api/userCase/' + params.id, {
    method: 'get',
    data: params,
  });
}

export async function queryDiseaseClass(params: any) {
  return request('/api/bsDiseaseClass/classId/' + params, {
    method: 'get',
  });
}

export async function queryDoctor(params: any) {
  return request('/api/doctor/selectByIdOrName?param=' + params, {
    method: 'get',
  });
}

export async function queryNewCaseDetail(params: any) {
  return request('/api/caseManage/' + params.id, {
    method: 'get',
    data: params,
  });
}

export async function list(params: any) {
  return request('/api/userCase/page', {
    method: 'POST',
    data: params,
  });
}

export async function caselist(params: any) {
  return request('/api/caseManage/page', {
    method: 'POST',
    data: params,
  });
}

/** 修改 PUT /api/Case */
export async function updateCase(params: any) {
  return request('/api/userCase/updateById', {
    method: 'PUT',
    data: params,
  });
}

/** 删除 DELETE /api/Case */
export async function removeCase(data: { key: number[] }, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/userCase/' + data.key, {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
